<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title>个人存款计算器</title>
		<link rel="shortcut icon" href="img/logo.png" type="imaga/x-icon">
		<script src="js/jquery.min.js" type="text/javascript" charset="utf-8"></script>
		<script src="js/bootstrap.min.js" type="text/javascript" charset="utf-8"></script>
		<link rel="stylesheet" href="css/bootstrap.min.css">
		<script type="text/javascript">
			function cale(){
				num1=$("#num1").val();
				regExp=/^[0-9]{1,8}$/;
				number1=parseInt(num1);
				year1=$("#year option:selected").text();
				if(!regExp.test(num1)){
					$("#num1").val("必须是1-8为数字！").css("color","red");
					return;
				}
				if(year1=="一年"){
					num2=$("#year").val()*number1*1
				}
				else if(year1=="二年"){
					num2=$("#year").val()*number1*2
				}
				else if(year1=="三年"){
					num2=$("#year").val()*number1*3
				}
				else if(year1=="五年"){
					num2=$("#year").val()*number1*5
				}
				
				$("#num2").val(num2);
				total=number1+num2;
				$("#num3").val(total);
			}
			function clearNum1(){
				$("#num1").val("").css("color","");
			}
		</script>
	</head>
	<body>
		<div style="width: 50%;" class="text-center center-block">
			<div>
				<img src="img/cmb.png" alt="">
			</div>
			<table class="table table-bordered">
				<tr class="bg-primary">
					<td colspan="2">个人存款计算</td>
				</tr>
				<tr>
					<td class="text-right">存款金额</td>
					<td><input onfocus="clearNum1()" class="form-control" type="text" id="num1"></td>
				</tr>
				<tr>
					<td class="text-right">存款期限</td>
					<td>
						<select class="form-control" id="year">
							<option value ="">请选择</option>
							<option value="0.0175">一年</option>
							<option value="0.0225">二年</option>
							<option value="0.0275">三年</option>
							<option value="0.0275">五年</option>
						</select>
					</td>
				</tr>
				<tr>
					<td class="text-right">所得利息</td>
					<td>
						<input readonly="readonly" type="text" class="form-control" id="num2">
					</td>
				</tr>
				<tr>
					<td class="text-right">本息合计</td>
					<td>
						<input readonly="readonly" type="text" class="form-control" id="num3">
					</td>
				</tr>
				<tr>
					<td colspan="2">
						<button onclick="cale()" type="button" class="btn btn-block btn-primary">开始计算</button>
					</td>
				</tr>
			</table>
			<div>
				开发者：182055215迪天祥
			</div>
		</div>
	</body>
</html>
